//
//  ExploreTableViewController.swift
//  Wechat1.0
//
//  Created by gaoyi on 2017/11/6.
//  Copyright © 2017年 gaoyi. All rights reserved.
//

import UIKit

class ExploreTableViewController: UITableViewController {

    let titleArray = [["朋友圈"],["扫一扫","摇一摇"],["附近的人","漂流瓶"],["游戏"]]
    let imageArray = [["moments.jpg"],["QR.jpg","Shake.jpg"],["People.jpg","Bottle.jpg"],["Game.jpg"]]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tableView = UITableView.init(frame: UIScreen.main.bounds, style: .grouped)
        tableView.dataSource = self
        tableView.delegate = self
        view.addSubview(tableView)
    }
    
    override func numberOfSections(in tableView: UITableView) -> Int {
        return 4
    }
    override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 10
    }
    override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 5
    }
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if section == 0
        {
            return 1
        }
        else if section == 1 || section == 2
        {
            return 2
        }
            else if section == 3
        {
            return 1
        }
        else {
            return 0
        }
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = UITableViewCell.init(style: .default, reuseIdentifier: nil)
        
        let imageView = UIImageView.init(frame: CGRect(x: 10, y: 10, width: 24, height: 24))
        imageView.image = UIImage(named: imageArray[indexPath.section][indexPath.row])
        cell.contentView.addSubview(imageView)
        
        let label = UILabel.init(frame: CGRect(x: 44, y: 12, width: 100, height: 20))
        label.text = titleArray[indexPath.section][indexPath.row]
        cell.contentView.addSubview(label)
        
        let label2 = UILabel.init(frame: CGRect(x: 352, y: 12, width: 15, height: 20))
        label2.text = "›"
        label2.font = UIFont.systemFont(ofSize: 28)
        label2.textColor = UIColor.darkGray
        cell.contentView.addSubview(label2)
        return cell
    }

    /*
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)

        // Configure the cell...

        return cell
    }
    */

    /*
    // Override to support conditional editing of the table view.
    override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
        // Return false if you do not want the specified item to be editable.
        return true
    }
    */

    /*
    // Override to support editing the table view.
    override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
        if editingStyle == .delete {
            // Delete the row from the data source
            tableView.deleteRows(at: [indexPath], with: .fade)
        } else if editingStyle == .insert {
            // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
        }    
    }
    */

    /*
    // Override to support rearranging the table view.
    override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {

    }
    */

    /*
    // Override to support conditional rearranging of the table view.
    override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
        // Return false if you do not want the item to be re-orderable.
        return true
    }
    */

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
